From: kaf24@firebug.cl.cam.ac.uk Date: Fri, 12 May 2006 14:19:37 +0000 (+0100) Subject: Fix xentrace to initialise the trace buffers if they are not set up. X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~16047^2~78 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/success//%22http:/www.example.com/cgi/success/?a=commitdiff_plain;h=4550aad32daf554b43a9eae969722b557d39da97;p=xen.git Fix xentrace to initialise the trace buffers if they are not set up. Signed-off-by: Atsushi SAKAI --- diff --git a/tools/xentrace/xentrace.c b/tools/xentrace/xentrace.c index e001704d2c..b3a6b47a52 100644 --- a/tools/xentrace/xentrace.c +++ b/tools/xentrace/xentrace.c @@ -28,6 +28,8 @@ #include +#include "xc_private.h" + #define PERROR(_m, _a...) \ do { \ int __saved_errno = errno; \ @@ -46,7 +48,7 @@ extern FILE *stderr; /* sleep for this long (milliseconds) between checking the trace buffers */ #define POLL_SLEEP_MILLIS 100 - +#define DEFAULT_TBUF_SIZE 20 /***** The code **************************************************************/ typedef struct settings_st { @@ -101,6 +103,26 @@ void write_rec(unsigned int cpu, struct t_rec *rec, FILE *out) } } +void enable_tracing_or_die(int xc_handle) +{ + int enable = 1; + int tbsize = DEFAULT_TBUF_SIZE; + + if (xc_tbuf_enable(xc_handle, enable) != 0) { + if (xc_tbuf_set_size(xc_handle, tbsize) != 0) { + perror("set_size Hypercall failure"); + exit(1); + } + printf("Set default trace buffer allocation (%d pages)\n", tbsize); + if (xc_tbuf_enable(xc_handle, enable) != 0) { + perror("Could not enable trace buffers\n"); + exit(1); + } + } + else + printf("Tracing enabled\n"); +} + /** * get_tbufs - get pointer to and size of the trace buffers * @mfn: location to store mfn of the trace buffers to @@ -111,22 +133,37 @@ void write_rec(unsigned int cpu, struct t_rec *rec, FILE *out) */ void get_tbufs(unsigned long *mfn, unsigned long *size) { - uint32_t size32; + int ret; + dom0_op_t op; /* dom0 op we'll build */ int xc_handle = xc_interface_open(); /* for accessing control interface */ + unsigned int tbsize; - if (xc_tbuf_get_size(xc_handle, &size32) != 0) - goto fail; - *size = size32; + enable_tracing_or_die(xc_handle); - if (xc_tbuf_get_mfn(xc_handle, mfn) != 0) - goto fail; + if (xc_tbuf_get_size(xc_handle, &tbsize) != 0) { + perror("Failure to get tbuf info from Xen. Guess size is 0?"); + exit(1); + } + else + printf("Current tbuf size: 0x%x\n", tbsize); + + + op.cmd = DOM0_TBUFCONTROL; + op.interface_version = DOM0_INTERFACE_VERSION; + op.u.tbufcontrol.op = DOM0_TBUF_GET_INFO; + + ret = do_dom0_op(xc_handle, &op); xc_interface_close(xc_handle); - return; -fail: - PERROR("Failure to get trace buffer pointer from Xen"); - exit(EXIT_FAILURE); + if ( ret != 0 ) + { + PERROR("Failure to get trace buffer pointer from Xen"); + exit(EXIT_FAILURE); + } + + *mfn = op.u.tbufcontrol.buffer_mfn; + *size = op.u.tbufcontrol.size; } /**